package com.esun.cheetah.biz.personal.personalcommunicater.sportlottery;

import java.util.ArrayList;
import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Handler;

import com.esun.cheetah.biz.personal.personalinfo.UserInfo;
import com.esun.cheetah.network.AbsInferiorityCommunicater;
import com.esun.cheetah.view.personal.sportlotteryfootballinfo.SportteryFootballAgainstInfo;

import com.esun.util.log.EDebug;

/**
 * 
 * @Package com.esun.cheetah.biz.personal.personalcommunicater.sportlottery.SportteryFootballNoFilterAgainstInfoCommunicater
 * @ClassName: SportteryFootballNoFilterAgainstInfoCommunicater
 * @Description: TODO(football no filter against info communication)
 * @author handy <br/>
 * @date create at 2012-7-31 下午3:07:35
 *
 */
public class SportteryFootballNoFilterAgainstInfoCommunicater extends
		AbsInferiorityCommunicater {

	private String order = "";

	private String status;
	private String msg;
	private double money;
	private String data;
	private String freezemoney;
	private String ck;
	private ArrayList<SportteryFootballAgainstInfo> listSportteryFootballAgainstInfos = new ArrayList<SportteryFootballAgainstInfo>();
	private String[] leagueNames;
	private String username = "";
	private String userpass = "";

	public SportteryFootballNoFilterAgainstInfoCommunicater(Handler handler) {
		super(handler);
	}

	@Override
	public HashMap<String, String> comHashMap() {
		HashMap<String, String> hmJson = new HashMap<String, String>();

		hmJson.put("id", "10072");
		hmJson.put("lotName", "jczq");

		return hmJson;
	}

	/**
	 * @throws JSONException
	 * @Title: getJsonContent
	 * @Description: 解析json
	 * @param
	 * @return Object
	 * @throws
	 */
	@Override
	public void getJsonContent(String serverRes) throws JSONException {

		JSONObject json = new JSONObject(serverRes);
		status = json.getString("status");
		msg = json.getString("msg");
		UserInfo.getUserInfo().setMsg(msg);
		EDebug.o("msg---" + msg);
		EDebug.o("status---" + status);
		if ("true".equals(status)) {
			JSONObject jsondata = new JSONObject(json.getString("data"));
			JSONArray leagues = jsondata.getJSONArray("league");
			leagueNames = new String[leagues.length()];

			for (int i = 0; i < leagues.length(); i++) {
				leagueNames[i] = leagues.getString(i);
			}

			EDebug.o("jsonArray------" + leagueNames);

			JSONArray jsonArray = jsondata.getJSONArray("list");
			EDebug.o("jsonArray------" + jsonArray);
			for (int i = 0; i < jsonArray.length(); i++) {

				SportteryFootballAgainstInfo sportteryFootballAgainstInfo = new SportteryFootballAgainstInfo();
				JSONObject localJs = jsonArray.optJSONObject(i);
				if (localJs != null) {
					// status = localJs.getInt(Key.KEY_STATUS);
					String infoid = localJs.getString("infoid");
					EDebug.o("infoid---" + infoid);
					sportteryFootballAgainstInfo.setInfoid(infoid);
					String matchnum = localJs.getString("matchnum");
					EDebug.o("matchnum---" + matchnum);
					sportteryFootballAgainstInfo.setMatchnum(matchnum);
					String fixtureid = localJs.getString("fixtureid");
					EDebug.o("fixtureid---" + fixtureid);
					sportteryFootballAgainstInfo.setFixtureid(fixtureid);
					String simpleleague = localJs.getString("simpleleague");
					EDebug.o("simpleleague---" + simpleleague);
					sportteryFootballAgainstInfo.setSimpleleague(simpleleague);
					String date = localJs.getString("date");
					EDebug.o("date---" + date);
					sportteryFootballAgainstInfo.setDate(date);
					String week = localJs.getString("week");
					EDebug.o("week---" + week);
					sportteryFootballAgainstInfo.setWeek(week);
					String homeid = localJs.getString("homeid");
					EDebug.o("homeid---" + homeid);
					sportteryFootballAgainstInfo.setHomeid(homeid);
					String homesxname = localJs.getString("homesxname");
					EDebug.o("homesxname---" + homesxname);
					sportteryFootballAgainstInfo.setHomesxname(homesxname);
					String homestanding = localJs.getString("homestanding");
					EDebug.o("homestanding---" + homestanding);
					sportteryFootballAgainstInfo.setHomestanding(homestanding);
					String awayid = localJs.getString("awayid");
					EDebug.o("awayid---" + awayid);
					sportteryFootballAgainstInfo.setAwayid(awayid);
					String awaysxname = localJs.getString("awaysxname");
					EDebug.o("awaysxname---" + awaysxname);
					sportteryFootballAgainstInfo.setAwaysxname(awaysxname);
					String awaystanding = localJs.getString("awaystanding");
					EDebug.o("awaystanding---" + awaystanding);
					sportteryFootballAgainstInfo.setAwaystanding(awaystanding);
					String matchtime = localJs.getString("matchtime");
					EDebug.o("matchtime---" + matchtime);
					sportteryFootballAgainstInfo.setMatchtime(matchtime);
					String rangqiu = localJs.getString("rangqiu");
					EDebug.o("rangqiu---" + rangqiu);
					sportteryFootballAgainstInfo.setRangqiu(rangqiu);
					String id = localJs.getString("id");
					EDebug.o("id---" + id);
					sportteryFootballAgainstInfo.setId(id);
					String status = localJs.getString("status");
					EDebug.o("status---" + status);
					sportteryFootballAgainstInfo.setStatus(status);
					String processname = localJs.getString("processname");
					EDebug.o("processname---" + processname);
					sportteryFootballAgainstInfo.setProcessname(processname);
					String win = localJs.getString("win");
					EDebug.o("win---" + win);
					sportteryFootballAgainstInfo.setWin(win);
					String draw = localJs.getString("draw");
					EDebug.o("draw---" + draw);
					sportteryFootballAgainstInfo.setDraw(draw);
					String lost = localJs.getString("lost");
					EDebug.o("lost---" + lost);
					sportteryFootballAgainstInfo.setLost(lost);
					String endtime = localJs.getString("endtime");
					EDebug.o("endtime---" + endtime);
					sportteryFootballAgainstInfo.setEndtime(endtime);

				}
				EDebug.o("=--------------------------------------------------");
				EDebug.o("=--------------------------------------------------");
				listSportteryFootballAgainstInfos
						.add(sportteryFootballAgainstInfo);
				EDebug.o("listSportteryFootballAgainstInfos-0---"
						+ listSportteryFootballAgainstInfos);
			}
			EDebug.o("listSportteryFootballAgainstInfos--1--"
					+ listSportteryFootballAgainstInfos);
		}

		// freezemoney = jsondata.getString("freezemoney");
		// EDebug.o("freezemoney----" + freezemoney);
		// setCk(jsondata.getString("ck"));
		// EDebug.o("ck----" + ck);
		// UserInfo.getUserInfo().setCk(ck);
		// UserInfo.getUserInfo().setUserName(username);
		// UserInfo.getUserInfo().setMoney(money);
		// }

	}

	public ArrayList<SportteryFootballAgainstInfo> getAgainstInfoList() {
		// listSportteryFootballAgainstInfos.get(location)
		return listSportteryFootballAgainstInfos;

	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getMsg() {
		return this.msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public double getMoney() {
		return this.money;
	}

	public void setMoney(double money) {
		this.money = money;
	}

	public String getData() {
		return this.data;
	}

	public void setData(String data) {
		this.data = data;
	}

	public String getFreezemoney() {
		return this.freezemoney;
	}

	public void setFreezemoney(String freezemoney) {
		this.freezemoney = freezemoney;
	}

	public String getCk() {
		return this.ck;
	}

	public void setCk(String ck) {
		this.ck = ck;
	}

	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getUserpass() {
		return this.userpass;
	}

	public void setUserpass(String userpass) {
		this.userpass = userpass;
	}

	// public int getStatus() {
	// return this.status;
	// }
	//
	// public void setStatus(int status) {
	// this.status = status;
	// }
	//
	public String getOrder() {
		return this.order;
	}

	public ArrayList<SportteryFootballAgainstInfo> getListSportteryFootballAgainstInfos() {
		return this.listSportteryFootballAgainstInfos;
	}

	public void setListSportteryFootballAgainstInfos(
			ArrayList<SportteryFootballAgainstInfo> listSportteryFootballAgainstInfos) {
		this.listSportteryFootballAgainstInfos = listSportteryFootballAgainstInfos;
	}

	public String[] getLeagueNames() {
		return leagueNames;
	}

}
